package com.test2015.Swing;

import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JSplitPane;

public class JSplitPaneTest extends JFrame{
	JSplitPane vPane = null;
	JSplitPane hPane = null;
	
	JPanel bottom = new JPanel();
	JPanel top = new JPanel();
	
	JPanel left = new JPanel();
	JPanel right = new JPanel();
	
	public JSplitPaneTest(){

		Container pane = this.getContentPane();
		vPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
		hPane = new JSplitPane();
		
		vPane.setTopComponent(hPane);
		vPane.setBottomComponent(bottom);
		
		hPane.setPreferredSize(new Dimension(700,500));
		bottom.setPreferredSize(new Dimension(700,100));
		
		hPane.setLeftComponent(left);
		hPane.setRightComponent(right);
		right.setPreferredSize(new Dimension(700,0));
		
		right.setBackground(Color.red);
		left.setBackground(Color.yellow);
		bottom.setBackground(Color.green);
		
		hPane.setDividerSize(5);
		hPane.setDividerLocation(50);
		pane.add(vPane);
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		this.pack();
		this.setLocationRelativeTo(null);
		this.setVisible(true);
	}
	
	public static void main(String[] args) throws InterruptedException {
		JSplitPaneTest jSplitPaneTest = new JSplitPaneTest();
//		jSplitPaneTest.dispose();
//		Thread.sleep(2000);
//		jSplitPaneTest.setVisible(true);
		
	}
}
